﻿<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>驰骋BPM</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../../Scripts/jquery/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Comm/JS/validation.js"></script>
    <base target="_self" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />

    <script type="text/javascript">

        document.onkeydown = function (e) {
            e = e || window.event;
            if (e.keyCode == 13) {
                Login();
                return false;
            }
        }

        //初始化页面函数.....
        $(function () {

            if (! +[1,]) {
                //  alert("这是ie浏览器，您只能使用sliverlight版本浏览器。");
                // window.location.href = '../XAP/Designer.htm';
                // return;
            }

            $("#Msg").html("<img src='../../Img/loading.gif' /><font color=blue>ccbpm 正在为登录/自动升级做准备.</font>");

            document.getElementById("Btn_Login").disabled = 'disabled';
            // document.getElementById("Btn_LoginSimple").disabled = 'disabled';

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_CCBPMDesigner");
            var data = handler.DoMethodReturnJSON("Login_InitInfo");
            document.title = data.SysName;

            //执行更新检查..
            var doType = GetQueryString("DoType");
            if (doType == null)
                doType = "Login_Init";
            handler.AddUrlData();
            data = handler.DoMethodReturnString(doType);

            if (data.indexOf('err@') == 0) {

                $("#Msg").html("<font color=red>" + data + ". 也许是: java/.net/phtyon 运行环境没有准备好导致的. 请确认运行环境</font>");
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }

            document.getElementById("Btn_Login").disabled = false;
            // document.getElementById("Btn_LoginSimple").disabled = false;

            $("body").keydown(function () {
                if (event.keyCode == 13) {
                    event.cancelBubble = true;
                    event.returnValue = false;
                    Login();
                }
            });

            $("#Msg").html("<font color=green>" + data + "</font>");

        });

        //执行后台登录.
        function Login() {

            $("#Msg").html("<font> ccbpm 正在登录流程&表单引擎设计器,请稍候... </font>");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_CCBPMDesigner");

            var userNo = $("#TB_No").val();
            var pass = $("#TB_PW").val();

            if (userNo == "" || pass == "") {
                $("#Msg").html("<font>请输入用户名，密码.</font>");
                return;
            }

            //判断验证码是否正确
            var node = $("#validate");
            if (node.is(':visible')) {
                if (!validateCode()) {
                    return;
                }
            }
            handler.AddPara("TB_No", userNo);
            handler.AddPara("TB_PW", pass);

            var data = handler.DoMethodReturnString("Login_Submit");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                $("#validate").show();
                createCode();
                return;
            }

            if (data.indexOf("Install") != -1) {
                var data = data.replace('url@', '');
                window.location.href = data;
                return;
            }

            var systemp = $("#DDL_System").val();
            if (data.indexOf('url@') == 0) {
                var data = data.replace('url@', '');
                window.location.href = data.replace("Default.htm", systemp + ".htm");
                return;
            }
            alert(data);
        }

        // 选择系统后登录.
        function SelectChange() {
            var val = $("#DDL_System").val();
        }
        //设置cookies值
        function setCookie(cname, cvalue, exdays) {
            var d = new Date();
            d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
            var expires = "expires=" + d.toGMTString();
            document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        }
        //获取cookies值
        function getCookie(cname) {
            var name = cname + "=";
            var decodedCookie = decodeURIComponent(document.cookie);
            var ca = decodedCookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1);
                }
                if (c.indexOf(name) == 0) {
                    return c.substring(name.length, c.length);
                }
            }
            return "";
        }
        //检查cookies值
        function checkCookie() {
            var user = getCookie("username");
            if (user != "") {
                $(" select option[value='" + user + "']").attr("selected", "selected");
            } else {

                if (user != "" && user != null) {
                    setCookie("username", user, 30);
                }
            }
        }
    </script>


</head>
<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message">驰骋BPM@Opencc</div>
        <div id="darkbannerwrap"></div>

        <form method="post" class="layui-form">
            <div class="form-group">
                <b>您要登录的系统:</b>
                <select class="form-control" style="width:auto;display:inline" id="DDL_System" onchange="SelectChange()">
                    <option value="Default" onclick="setCookie('username', $(this).val(), 30)"> 驰骋BPM专业版 </option>
                    <option value="DefaultSimple" onclick="setCookie('username', $(this).val(), 30)">驰骋BPM极简版(beta)</option>
                    <option value="DefaultFrm" onclick="setCookie('username', $(this).val(), 30)"> 驰骋表单引擎(beta)</option>
                    <option value="DefaultGPM" onclick="setCookie('username', $(this).val(), 30)"> 驰骋权限管理(beta)</option>
                </select>
            </div>

            <input name="username" placeholder="用户名" type="text" id="TB_No" lay-verify="required" class="layui-input">
            <hr class="hr15">
            <input name="password" lay-verify="required" id="TB_PW" placeholder="密码" type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" onclick="Login();" lay-submit lay-filter="login" style="width:100%;" type="button" id="Btn_Login">
            <div id="Msg"></div>
            <hr class="hr20">

            <div id="validate" class="form-group" style="display: none">

                <input type="text" class="form-control" placeholder="验证码" id="inputCode" style="width:50%;display: inline" />
                <canvas id="canvas" width="78" height="24"></canvas>
                <a href="javascript:void(0)" style="margin-left: 10px" onclick="createCode()">看不清</a>
            </div>

        </form>
    </div>

    <!--<script>
        $(function () {
            layui.use('form', function () {
                var form = layui.form;
                // layer.msg('玩命卖萌中', function(){
                //   //关闭后的操作
                //   });
                //监听提交
                form.on('submit(login)', function (data) {
                    // alert(888)
                    layer.msg(JSON.stringify(data.field), function () {
                        location.href = 'index.html'
                    });
                    return false;
                });
            });
        })
    </script>-->


</body>
</html>